#include <cstdint>
#include <iostream>
#include <istream>
#include <queue>
#include <vector>

using ll = int64_t;
#define sl static inline

std::vector<std::vector<ll>> edg;
ll T,n;
std::vector<std::priority_queue<ll>> pq;

sl void merge(ll f,ll s){
    
}

sl void dfs(ll u){
    for(auto v:edg[u]){
        dfs(v);
        
    }
}

sl void solve(){
    std::cin>>n;
    edg.clear();
    pq.clear();
    pq.resize(n+1);
    edg.resize(n+1);
    for(ll i=1;i<=n-1;i++){
        ll u,v;
        std::cin>>u>>v;
        edg[u].emplace_back(v);
        edg[v].emplace_back(u);
    }
    dfs(1);
}

int main(){
    std::iostream::sync_with_stdio(false);
    std::cin.tie(nullptr);

    std::cin>>T;
    while(T--){
        solve();
    }
}